Filter hook 'option_page_capability_{$option_page}'

in WP Core File wp-admin/options.php at line 46

View Source

option_page_capability_{$option_page}

Filter Hook
Description
Filters the capability required when using the Settings API. By default, the options groups for all registered settings require the manage_options capability. This filter is required to change the capability required for a certain options page.

Hook Information

File Location wp-admin/options.php View on GitHub
Hook Type Filter
Line Number 46

Hook Parameters

Type Name Description
string $capability The capability used for the page, which is manage_options by default.

Usage Examples

Basic Usage
<?php
// Hook into option_page_capability_{$option_page}
add_filter('option_page_capability_{$option_page}', 'my_custom_filter', 10, 1);

function my_custom_filter($capability) {
    // Your custom filtering logic here
    return $capability;
}

Source Code Context

wp-admin/options.php:46 - How this hook is used in WordPress core
<?php
  41  	 *
  42  	 * @since 3.2.0
  43  	 *
  44  	 * @param string $capability The capability used for the page, which is manage_options by default.
  45  	 */
  46  	$capability = apply_filters( "option_page_capability_{$option_page}", $capability );
  47  }
  48  
  49  if ( ! current_user_can( $capability ) ) {
  50  	wp_die(
  51  		'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .

PHP Documentation

<?php
/**
	 * Filters the capability required when using the Settings API.
	 *
	 * By default, the options groups for all registered settings require the manage_options capability.
	 * This filter is required to change the capability required for a certain options page.
	 *
	 * @since 3.2.0
	 *
	 * @param string $capability The capability used for the page, which is manage_options by default.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-admin/options.php
Related Hooks

Related hooks will be displayed here in future updates.